package pkg

import (
	"encoding/json"
	"github.com/Baidu-AIP/golang-sdk/aip/censor"
)

type Res struct {
	ConclusionType int `json:"conclusionType"`
}

func Baidu(message string) (bool, error) {
	//通过access_toke
	client := censor.NewClient("XiiJ37Po6uAAltXl3qqyEt0u", "LWau5Jbov15GBN7nPZmUYHpva5MXAUG1")
	result := client.TextCensor(message)
	var res Res
	err := json.Unmarshal([]byte(result), &res)
	if err != nil {
		return false, err
	}
	return res.ConclusionType == 1, nil
}
